package com.carlwang.validate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ValidateManager {

	private Validator mValidator;

	public Validator getValidator() {
		return mValidator;
	}

	public void setValidator(Validator validator) {
		mValidator = validator;
	}

	public void executevalidate(Object[] paramArrayOfObject,
			String paramString, Map<String, String> paramMap) {
		Map filedBeanMap = fillFieldDate(paramArrayOfObject, paramString);
		if(getValidator()==null)
		{
			setValidator(new Validator());
		}
		getValidator().validate(filedBeanMap, null);
	}

	private Map<String, List<Object>> fillFieldDate(
			Object paramArrayOfObject[], String paramString) {
		Map<String, List<Object>> fieldBeanMap = new HashMap<String, List<Object>>();
		ArrayList<Object> localArrayList = new ArrayList<Object>();
		for (Object obj : paramArrayOfObject) {
			localArrayList.add(obj);
		}
		fieldBeanMap.put(paramString, localArrayList);
		return fieldBeanMap;
	}

	public void validateUserName(String pUserName) {
		String[] fileds = { pUserName };
		executevalidate(fileds,
				"com.carlwang.validate.checker.UserNameChecker", null);
	}
	
}
